const webpack = require('webpack');
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');

const isProd = process.env.NODE_ENV === 'production';

const plugins = isProd
  ? [
      new ReplaceInFileWebpackPlugin([
        {
          dir: 'dist/renderer/',
          files: ['index.html'],
          rules: [
            {
              search: '<script>require("source-map-support/source-map-support.js").install()</script>',
              replace: '',
            },
          ],
        },
      ]),
    ]
  : [];
module.exports = {
  devtool: isProd ? false : 'eval-source-map',
  plugins: [
    new webpack.DefinePlugin({
      'process.browser': 'true',
      __dev: process.env.forceDev,
    }),
    ...plugins,
  ],
};
